home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / util / qt < prev    next >
Encoding:
Internet Message Format  |  1990-03-03  |  13.1 KB

  1. Path: xanth!cs.odu.edu!Amiga-Request
  2. From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v90i090: Qt - what time is it toy, Part01/01
  5. Message-ID: <11614@xanth.cs.odu.edu>
  6. Date: 3 Mar 90 21:04:21 GMT
  7. Sender: tadguy@cs.odu.edu
  8. Reply-To: mjl@alison.at (Martin J. Laubach)
  9. Lines: 575
  10. Approved: tadguy@cs.odu.edu (Tad Guy)
  11. X-Mail-Submissions-To: Amiga@cs.odu.edu
  12. X-Post-Discussions-To: comp.sys.amiga
  13.  
  14. Submitted-by: mjl@alison.at (Martin J. Laubach)
  15. Posting-number: Volume 90, Issue 090
  16. Archive-name: util/qt
  17.  
  18. [ uuencoded binary enclosed.  ...tad ]
  19.  
  20.        This is one of my favorite toys -- though it's only about 400
  21.      bytes, it's a working "can anybody tell me what time it is?"
  22.      tool. Perfect for anybody's startup-sequence.  
  23.  
  24. #!/bin/sh
  25. # This is a shell archive.  Remove anything before this line, then unpack
  26. # it by saving it into a file and typing "sh file".  To overwrite existing
  27. # files, type "sh file -c".  You can also feed this as standard input via
  28. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  29. # will see the following message at the end:
  30. #        "End of archive 1 (of 1)."
  31. # Contents:  Makefile qt.asm qt.doc qt.uu
  32. # Wrapped by tadguy@xanth on Sat Mar  3 16:04:11 1990
  33. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  34. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  35.   echo shar: Will not clobber existing file \"'Makefile'\"
  36. else
  37. echo shar: Extracting \"'Makefile'\" \(187 characters\)
  38. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  39. XALL    = qt
  40. XOBJ    = qt.o
  41. XLFLAGS  = sc sd nd verbose
  42. XINCLUDE = inc:include.i
  43. X
  44. X
  45. X$(ALL):    $(OBJ)
  46. X    blink $(OBJ) $(LFLAGS) lib lib:amiga.lib
  47. X
  48. Xqt.o:    qt.asm
  49. X    casm -a qt.asm -o qt.o -c v -i $(INCLUDE)
  50. END_OF_FILE
  51. if test 187 -ne `wc -c <'Makefile'`; then
  52.     echo shar: \"'Makefile'\" unpacked with wrong size!
  53. fi
  54. # end of 'Makefile'
  55. fi
  56. if test -f 'qt.asm' -a "${1}" != "-c" ; then 
  57.   echo shar: Will not clobber existing file \"'qt.asm'\"
  58. else
  59. echo shar: Extracting \"'qt.asm'\" \(3761 characters\)
  60. sed "s/^X//" >'qt.asm' <<'END_OF_FILE'
  61. X; Qt -- What time is it?
  62. X;
  63. X; Original version (c) 1989 by Martin Laubach
  64. X; Heavy modifications (c) Jim Butterfield Jan 31, 1990
  65. X; Beautified by mjl
  66. X;
  67. X; :ts=12
  68. X
  69. X    include "exec/types.i"
  70. X    include "libraries/dos.i"
  71. X
  72. X    optimon
  73. X
  74. X;-----------------------------------------------------------------
  75. Xcall    macro
  76. X    xref    _LVO\1
  77. X    jsr     _LVO\1(a6)
  78. X    endm
  79. X
  80. Xvector    macro
  81. X    dc.b    \1-Hr12
  82. X    endm
  83. X
  84. X;-----------------------------------------------------------------
  85. X; Local variables
  86. X
  87. XLocal_SIZE:    equ     ds_SIZEOF    ; I need a local DateStamp
  88. X
  89. XToday:    equ     -Local_SIZE
  90. X
  91. X;-----------------------------------------------------------------
  92. X    section Qt,code
  93. X
  94. XMain:    link    a4,#-Local_SIZE
  95. X
  96. X    move.l  4,a6
  97. X
  98. X    lea     DosName(pc),a1
  99. X    moveq   #33,d0
  100. X    call    OpenLibrary
  101. X    move.l  d0,a6
  102. X
  103. X    call    Output
  104. X    move.l  d0,a5
  105. X
  106. X    lea     Today(a4),a0
  107. X    move.l  a0,d1
  108. X    call    DateStamp
  109. X
  110. X    move.l  Today+ds_Minute(a4),d6
  111. X    moveq   #27,d7
  112. X    add.l   d7,d6   
  113. X
  114. X    divu    #60,d6
  115. X    move.w  d6,d7        ; hours (quotient)
  116. X
  117. X    moveq   #12,d4
  118. X    divu    d4,d7        ; 
  119. X
  120. X    clr.w   d7
  121. X    swap    d7            ; hours (0-11)
  122. X
  123. X    clr.w   d6
  124. X    swap    d6            ; mins (remainder)
  125. X
  126. X    moveq   #It.vec-Hr.vecs,d0
  127. X    bsr.s   PutStr
  128. X
  129. X    divu    #5,d6        ; clock divisions
  130. X    swap    d6            ; 'almost' adjustment
  131. X    moveq   #Ny.vecs-Hr.vecs,d0
  132. X    add.w   d6,d0
  133. X    bsr.s   PutStr
  134. X
  135. X    swap    d6            ; clock divisions
  136. X    moveq   #Ps.vec-Hr.vecs,d5
  137. X    subq.w  #5,d6        ; adjust to hour
  138. X    beq.s   Exact
  139. X    bpl.s   GotToP
  140. X
  141. X    moveq   #To.vec-Hr.vecs,d5
  142. X    neg.w   d6
  143. X
  144. XGotToP:    moveq   #Ft.vecs-Hr.vecs,d0
  145. X    add.w   d6,d0
  146. X    bsr.s   PutStr
  147. X
  148. X    move.l  d5,d0
  149. X    bsr.s   PutStr
  150. X
  151. XExact:    moveq   #Hr.vecs-Hr.vecs,d0
  152. X    add.w   d7,d0
  153. X    bsr.s   PutStr
  154. X
  155. X    moveq   #OC.vec-Hr.vecs,d0
  156. X    tst.w   d6
  157. X    bne.s   NoOclk
  158. X    bsr.s   PutStr
  159. X
  160. XNoOclk:    lea     NewLine.CHR(pc),a3
  161. X    bsr.s   Prt1
  162. X
  163. X
  164. X    move.l  a6,a1
  165. X    move.l  4,a6
  166. X    call    CloseLibrary
  167. X
  168. X    unlk    a4
  169. X    rts
  170. X
  171. X;-----------------------------------------------------------------
  172. X; Print item from table (Hr.vecs)
  173. X;   D0 = String number
  174. X; -->
  175. X;   Nil
  176. X
  177. XPutStr:    lea     Hr.vecs(pc),a0
  178. X    moveq   #0,d2
  179. X    moveq   #0,d3
  180. X
  181. X    move.b  0(a0,d0.w),d2        ; Get buffer offset
  182. X    move.b  1(a0,d0.w),d3        ; Get next item offset
  183. X    sub.w   d2,d3        ; Length of string
  184. X
  185. X    beq.s   Exit        ; No string
  186. X
  187. X    lea     Hr12(pc),a3        ; Begin of string table
  188. X    add.l   a3,d2        ; Begin of string
  189. X
  190. X;-----------------------------------------------------------------
  191. X; Print something + space
  192. X;   D2 = Pointer to something
  193. X;   D3 = Length of something
  194. X; -->
  195. X;   Nil
  196. X
  197. XPrtItem:    bsr.s   Put1
  198. X
  199. X    lea     Space.CHR(pc),a3
  200. X
  201. XPrt1:    move.l  a3,d2
  202. X    moveq   #1,d3
  203. X
  204. XPut1:    move.l  a5,d1           ; handle
  205. XGotstr:    call    Write
  206. X
  207. XExit:    moveq   #0,d0
  208. X    rts
  209. X
  210. X
  211. X;-----------------------------------------------------------------
  212. X; String vector table
  213. X
  214. XHr.vecs:    vector Hr12
  215. X    vector Hr01
  216. X    vector Hr02
  217. X    vector Hr03
  218. X    vector Hr04
  219. X    vector Hr05
  220. X    vector Hr06
  221. X    vector Hr07
  222. X    vector Hr08
  223. X    vector Hr09
  224. X    vector Hr10
  225. XFt.vecs:    vector Hr11
  226. X    vector Mn05
  227. X    vector Mn10
  228. X    vector Mn15
  229. X    vector Mn20
  230. X    vector Mn25
  231. X    vector Mn30
  232. XNy.vecs:    vector nearly
  233. X    vector almost
  234. X    vector justpast
  235. X    vector justpast
  236. X    vector after
  237. XIt.vec:    vector Itis
  238. XPs.vec:    vector Past
  239. XTo.vec:    vector UpTo
  240. XOC.vec:    vector OClock
  241. X    vector Space.CHR
  242. X
  243. X;-----------------------------------------------------------------
  244. X; Strings
  245. X
  246. XHr12:    dc.b 'twelve'
  247. XHr01:    dc.b 'one'
  248. XHr02:    dc.b 'two'
  249. XHr03:    dc.b 'three'
  250. XHr04:    dc.b 'four'
  251. XHr05:    dc.b 'five'
  252. XHr06:    dc.b 'six'
  253. XHr07:    dc.b 'seven'
  254. XHr08:    dc.b 'eight'
  255. XHr09:    dc.b 'nine'
  256. XHr10:    dc.b 'ten'
  257. XHr11:    dc.b 'eleven'
  258. XMn05:    dc.b 'five'
  259. XMn10:    dc.b 'ten'
  260. XMn15:    dc.b 'a quarter'
  261. XMn20:    dc.b 'twenty'
  262. XMn25:    dc.b 'twenty-five'
  263. XMn30:    dc.b 'half'
  264. Xnearly:    dc.b 'nearly' 
  265. Xalmost:    dc.b 'almost'
  266. Xjustpast:    dc.b 'just after'
  267. Xafter:    dc.b 'after'
  268. XItis:    dc.b 'It''s'
  269. XPast:    dc.b 'past'
  270. XUpTo:    dc.b 'to'
  271. XOClock:    dc.b 'o''clock'
  272. XSpace.CHR:    dc.b ' '
  273. XNewLine.CHR: dc.b 10
  274. XDosName:    dc.b 'dos.library',0
  275. X
  276. X    end
  277. X
  278. END_OF_FILE
  279. if test 3761 -ne `wc -c <'qt.asm'`; then
  280.     echo shar: \"'qt.asm'\" unpacked with wrong size!
  281. fi
  282. # end of 'qt.asm'
  283. fi
  284. if test -f 'qt.doc' -a "${1}" != "-c" ; then 
  285.   echo shar: Will not clobber existing file \"'qt.doc'\"
  286. else
  287. echo shar: Extracting \"'qt.doc'\" \(5132 characters\)
  288. sed "s/^X//" >'qt.doc' <<'END_OF_FILE'
  289. X
  290. X
  291. X     Page 1                 Qt's Documentation                  Page 1
  292. X
  293. X
  294. X
  295. X
  296. X
  297. X
  298. X
  299. X
  300. X
  301. X
  302. X
  303. X
  304. X
  305. X
  306. X
  307. X
  308. X
  309. X                                    Qt
  310. X                   (c) Copyright 1989 by Martin J. Laubach
  311. X                    (c) Copyright 1990 by Jim Butterfield
  312. X                            All rights reserved
  313. X
  314. X
  315. X
  316. X
  317. X
  318. X
  319. X
  320. X
  321. X  1. Introduction      
  322. X
  323. X       This is one of my favorite toys -- though it's only about 400
  324. X     bytes, it's a working "can anybody tell me what time it is?"
  325. X     tool. Perfect for anybody's startup-sequence.  
  326. X
  327. X  2. Internals      
  328. X
  329. X  2.1. Background    
  330. X
  331. X       Please don't yell at me because you don't like the look of the
  332. X     source -- I know I do some not-so-nice things (like putting data
  333. X     in the code hunk).  It was my explicit aim to shorten the
  334. X     program as much as possible, so I might not always have used the
  335. X     most elegant solution. However, this version is much more
  336. X     elegant than my first one -- kudos to Jim Butterfield.  
  337. X
  338. X  2.2. History    
  339. X
  340. X       It all began when I saw a similar tool on a PC (shame on me).
  341. X     I really loved it. So I tried to implement it in C -- the first
  342. X     version had about 4K. I really didn't like that since the PC
  343. X     version had only 512 bytes. So I began rewriting it in
  344. X     assembler, and after some code bumming, I ended up with 408
  345. X     bytes. I then posted it to alt.sources.amiga, and, though I
  346. X     thought my code pretty dense, I got mail from Jim Butterfield,
  347. X     telling me he succeeded in shortening the code -- with, at the
  348. X
  349. X
  350. X     Internals                                              History
  351. X
  352. X
  353. X     Page 2                 Qt's Documentation                  Page 2
  354. X
  355. X
  356. X     same time, making it pure, more readable, and not
  357. X     self-modifying. He really had an interesting idea of how to
  358. X     store and access the string table (see the code), an idea I
  359. X     would never had thought about.  
  360. X
  361. X  2.3. Challenge    
  362. X
  363. X       We are now down at a whopping 392 bytes. See if you can do
  364. X     better! 
  365. X
  366. X  3. What      
  367. X
  368. X       In this archive, you should find the following files: 
  369. X
  370. X             qt.doc .... What you are reading right now.
  371. X             qt.asm .... The source for rm.
  372. X             makefile .. Guess what.
  373. X             qt ........ The executable
  374. X
  375. X  4. Where      
  376. X
  377. X       If you have any comments, ideas what could or should be
  378. X     improved, bug reports or just like to chat a bit, please feel
  379. X     free to contact me at one of the following addresses... I just
  380. X     *love* receiving mail! 
  381. X
  382. X       Usenet:  mjl@alison.at 
  383. X                ..!uunet!mcsun!tuvie!alison!mjl 
  384. X
  385. X         or 
  386. X
  387. X       FidoNet: "Martin Laubach" at 2:310/3.14 
  388. X
  389. X
  390. X       Looking forward to reading from you, 
  391. X
  392. X             mjl 
  393. X
  394. X
  395. X       Jim Butterfield, who did not a small part of this, can also be
  396. X     reached on Usenet: 
  397. X
  398. X             jb@cbmtor.uucp 
  399. X             ..!uunet!cbmtor!jb.  
  400. X
  401. X
  402. X
  403. X  5. License      
  404. X
  405. X       This material is (c) Copyright 1989 by Martin J. Laubach and (c)
  406. X     Copyright 1990 by Jim Butterfield -- All rights reserved.  
  407. X
  408. X       It may be distributed freely as long as the following
  409. X     restrictions are met: 
  410. X
  411. X
  412. X     License
  413. X
  414. X
  415. X     Page 3                 Qt's Documentation                  Page 3
  416. X
  417. X
  418. X
  419. X       The distributor may charge a fee to recover distribution
  420. X     costs. The fee for diskette distribution should not be more than
  421. X     the cost to obtain the same diskette from Fred Fish.  
  422. X
  423. X       The distributor agrees to cease distributing the programs and
  424. X     data involved if requested to do so by the author.  
  425. X
  426. X       You may copy and distribute verbatim copies of the program's
  427. X     executable code and documentation as you receive it, in any
  428. X     medium, provided that you conspicuously and appropriately
  429. X     publish only the original, unmodified program, with all
  430. X     copyright notices and disclaimers of warranty intact and
  431. X     including all the accompanying documentation, example files and
  432. X     anything else that came with the original.  
  433. X
  434. X       The author will not be liable for any damage arising from the
  435. X     failure of this program to perform as described, or any
  436. X     destruction of other programs or data residing on a system
  437. X     attempting to run the program.  While I know of no damaging
  438. X     errors, the user of this program uses it at his or her own
  439. X     risk.  
  440. X
  441. X
  442. X
  443. X
  444. X
  445. X
  446. X
  447. X
  448. X
  449. X
  450. X
  451. X
  452. X
  453. X
  454. X
  455. X
  456. X
  457. X
  458. X
  459. X
  460. X
  461. X
  462. X
  463. X
  464. X
  465. X
  466. X
  467. X
  468. X
  469. X
  470. X
  471. X
  472. X
  473. X
  474. X     License
  475. X
  476. X
  477. X     Page 4                 Qt's Documentation                  Page 4
  478. X
  479. X
  480. X  6. Road Map    
  481. X
  482. X
  483. X
  484. X        1. Introduction     ....................................    1
  485. X        2. Internals     .......................................    1
  486. X           2.1. Background   ...................................    1
  487. X           2.2. History   ......................................    1
  488. X           2.3. Challenge   ....................................    2
  489. X        3. What     ............................................    2
  490. X        4. Where     ...........................................    2
  491. X        5. License     .........................................    2
  492. X        6. Road Map    .........................................    4
  493. X
  494. X
  495. X
  496. X
  497. X
  498. X
  499. X
  500. X
  501. X
  502. X
  503. X
  504. X
  505. X
  506. X
  507. X
  508. X
  509. X
  510. X
  511. X
  512. X
  513. X
  514. X
  515. X
  516. X
  517. X
  518. X
  519. X
  520. X
  521. X
  522. X
  523. X
  524. X
  525. X
  526. X
  527. X
  528. X
  529. X
  530. X
  531. X
  532. X
  533. X
  534. X
  535. X
  536. X     Road Map
  537. X
  538. END_OF_FILE
  539. if test 5132 -ne `wc -c <'qt.doc'`; then
  540.     echo shar: \"'qt.doc'\" unpacked with wrong size!
  541. fi
  542. # end of 'qt.doc'
  543. fi
  544. if test -f 'qt.uu' -a "${1}" != "-c" ; then 
  545.   echo shar: Will not clobber existing file \"'qt.uu'\"
  546. else
  547. echo shar: Extracting \"'qt.uu'\" \(580 characters\)
  548. sed "s/^X//" >'qt.uu' <<'END_OF_FILE'
  549. Xbegin 664 qt
  550. XM```#\P`````````!``````````````!9```#Z0```%E.5/_T+'@`!$/Z`4YP.
  551. XM(4ZN_=@L0$ZN_\0J0$'L__0B"$ZN_T`L+/_X?AO<AXS\`#P^!G@,CL1"1TA'-
  552. XM0D9(1G`784:,_``%2$9P$M!&83I(1GH86T9G$&H$>AE$1G`+T$9A)B`%82)P%
  553. XM`-!'81QP&DI&9@)A%$?Z`.%A+B).+'@`!$ZN_F).7$YU0?H`+'0`=@`4,```R
  554. XM%C```99"9Q9'^@`TU(MA"$?Z`+`D"W8!(@U.KO_0<`!.=0`&"0P1%1D<(28J$
  555. XM+3,W.D-)5%A>9&1N<W=[?81T=V5L=F5O;F5T=V]T:')E969O=7)F:79E<VEX(
  556. XM<V5V96YE:6=H=&YI;F5T96YE;&5V96YF:79E=&5N82!Q=6%R=&5R='=E;G1Y#
  557. XM='=E;G1Y+69I=F5H86QF;F5A<FQY86QM;W-T:G5S="!A9G1E<F%F=&5R270GF
  558. X@<W!A<W1T;V\G8VQO8VL@"F1O<RYL:6)R87)Y`````_)A9
  559. X``
  560. Xend
  561. Xsize 392
  562. END_OF_FILE
  563. if test 580 -ne `wc -c <'qt.uu'`; then
  564.     echo shar: \"'qt.uu'\" unpacked with wrong size!
  565. fi
  566. # end of 'qt.uu'
  567. fi
  568. echo shar: End of archive 1 \(of 1\).
  569. cp /dev/null ark1isdone
  570. MISSING=""
  571. for I in 1 ; do
  572.     if test ! -f ark${I}isdone ; then
  573.     MISSING="${MISSING} ${I}"
  574.     fi
  575. done
  576. if test "${MISSING}" = "" ; then
  577.     echo You have the archive.
  578.     rm -f ark[1-9]isdone
  579. else
  580.     echo You still need to unpack the following archives:
  581.     echo "        " ${MISSING}
  582. fi
  583. ##  End of shell archive.
  584. exit 0
  585. -- 
  586. Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
  587. Mail comments to the moderator at <amiga-request@cs.odu.edu>.
  588. Post requests for sources, and general discussion to comp.sys.amiga.
  589.